<?php
/*
 * @Author: 李明
 * @Date: 2021-10-28 11:51:29
 * @LastEditTime: 2021-11-30 18:06:04
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Models/OaModel.php
 * @山东壹零贰肆信息科技有限公司
 */

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;

/**
 * Class OaModel
 * 
 * @property int $id
 * @property string|null $name
 * @property string|null $content
 * @property int|null $group
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * 
 * @property Collection|OaFlow[] $oa_flows
 * @property Collection|Branch[] $branches
 *
 * @package App\Models
 */
class OaModel extends Model
{
    protected $table = 'oa_model';

    protected $casts = [
        'group' => 'int'
    ];

    protected $fillable = [
        'name',
        'content',
        'group'
    ];

    public function oa_flows()
    {
        return $this->hasMany(OaFlow::class);
    }

    public function branches()
    {
        return $this->belongsToMany(Branch::class, 'oa_model_branch')
            ->withPivot('id')
            ->withTimestamps();
    }
}
